<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<jsp:include page="global.jsp"></jsp:include>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>操作日志管理</title>
<style type="text/css">
.ctl{
	text-decoration: none;
	color: blue;
	margin: auto 7px;
}
.ctl:HOVER{
	text-decoration: underline;
}
.center{
	text-align: center;
}
</style>
</head>
<body>
	<table id="dg" class="easyui-datagrid" title="操作日志管理"
			data-options="
				rownumbers:true,
				iconCls: 'icon-edit',
				singleSelect: true,
				toolbar: '#tb',
				singleSelect:true,
				pagination:true,
				fit:true,
				fitColumns:true,
				pageList:[20,25,30,35,40,45,50],
				pageSize:20
			">
		<thead>
			<tr>
				<th data-options="field:'personName',width:200,align:'center'">被代理人姓名</th>
				<th data-options="field:'proxyPersonName',width:200,align:'center'">代理人姓名</th>
				<th data-options="field:'operationDateTime',width:150,align:'center'">操作时间</th>
				<th data-options="field:'operationType',width:200,align:'center'">操作类型</th>
				<th data-options="field:'object',width:100,align:'center'">对象标识</th>
				<th data-options="field:'id',width:50,align:'center',formatter:formatControl,align:'center'">管理</th>
			</tr>
		</thead>
	</table>

	<div id="tb" style="height:auto">
		<div>
			被代理人姓名:
			<select data-options="editable: false" id = "person" class="easyui-combobox">
				<option value = "-1"> --全部-- </option>
				<c:forEach var="item" items="${persons }" >
					<option value = "${item.id }">${item.name }</option>
				</c:forEach>
			</select>
			代理人姓名:
			<select data-options="editable: false" id = "proxyPerson" class="easyui-combobox">
				<option value = "-1"> --全部-- </option>
				<c:forEach var="item" items="${proxyPersons }" >
					<option value = "${item.id }">${item.name }</option>
				</c:forEach>
			</select>
			时间: <input class="easyui-datebox" type="text" id="startDatetime" style="width:100px;height:25px;">
			~ <input class="easyui-datebox" type="text" id="endDatetime" style="width:100px;height:25px;">
			<a href="javascript:search()" class="easyui-linkbutton" iconCls="icon-search">查 找</a>
		</div>
	</div>
	
	<div id="lookDetail" class="easyui-window" title="操作日志详情" data-options="modal:true,closed:true,iconCls:'icon-search'" style="width:720px; height:400px;padding:5px;">
		<div class="easyui-layout" data-options="fit:true">
			<div data-options="region:'center'" style="padding:10px;">
				<table width="100%" height="100%">
					<tr>
						<td width="170px;" align="right">被代理人姓名：</td>
						<td width="160px">
							<input class="easyui-textbox" id="lookPersonName" readonly="readonly" style="width: 200px;" />
						</td>
						<td width="140px;" align="right">代理人姓名：</td>
						<td>
							<input class="easyui-textbox" id="lookProxyPersonName" readonly="readonly" style="width: 200px;" />
						</td>
					</tr>
					<tr>
						<td align="right">操作时间：</td>
						<td>
							<input class="easyui-datebox" id="lookOperationDateTime" readonly="readonly" style="width: 200px;" />
						</td>
						<td align="right">操作类型：</td>
						<td>
							<input class="easyui-textbox" id="lookOperationType" readonly="readonly" style="width: 200px;" />
						</td>
					</tr>
					<tr>
						<td align="right">对象标识：</td>
						<td colspan="3">
							<input class="easyui-textbox" id="lookObject" readonly="readonly" style="width: 200px;" />
						</td>
					</tr>
					<tr>
						<td align="right">操作说明：</td>
						<td colspan="3">
							<input class="easyui-textbox" id="lookOperationDescription" style="width: 545px; height: 185px;" data-options="multiline:true" readonly="readonly" />
						</td>
					</tr>
				</table>
			</div>
			<div data-options="region:'south',border:false" style="text-align:right;padding:5px 0 0;">
				<a class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:void(0)" onclick="javascript:$('#lookDetail').window('close')" style="width:80px">关 闭</a>
			</div>
		</div>
	</div>
	
	<script type="text/javascript">
		function formatControl(val, row){
			return '<a class="ctl" href="javascript:void(0)" onclick="lookDetail(' + val + ')">查看</a>';
		}
		function search(){
			var dg = $("#dg");
			var person = $("#person").combobox("getValue");
			var proxyPerson = $("#proxyPerson").combobox("getValue");
			var startDatetime = $("#startDatetime").textbox("getValue").trim();
			var endDatetime = $("#endDatetime").textbox("getValue").trim();
			var url = "queryOperationLog?proxyPersonId=" + proxyPerson + "&personId=" + person + "&startDatetime=" + startDatetime + "&endDatetime=" + endDatetime;
			dg.datagrid('reload', url);
		}
		function lookDetail(id){
			var data = "id=" + id;
			$.ajax({
			  	type: "GET",
			  	url: "findOperationLog",
			  	data: data,
			  	success:function(data){
					var val = $.parseJSON(data);
					if(val.success){
						var item = val.data;

						$("#lookPersonName").textbox("setValue", item.personName);
						$("#lookProxyPersonName").textbox("setValue", item.proxyPersonName);
						$("#lookOperationType").textbox("setValue", item.operationType);
						$("#lookObject").textbox("setValue", item.object);
						$("#lookOperationDateTime").textbox("setValue", item.operationDateTime);
						$("#lookOperationDescription").textbox("setValue", item.operationDescription);
						
						$('#lookDetail').window('open');
					}else{
						$.messager.alert("提示", val.msg, "error");
					}
			  	}
			});
		}
		$(function(){
			search();
		});
	</script>
</body>
</html>